import java.util.Stack;

public class MinStack {
  private Stack<Integer> minStack;
  private Stack<Integer> mainStack;

  //构造器初始化值
  public MinStack() {
    minStack = new Stack<>();
    mainStack = new Stack<>();
    minStack.push(Integer.MAX_VALUE);
  }
  public void push(Integer a){
    mainStack.push(a);
    minStack.push(Math.min(minStack.peek(),a));
  }
  public void pop(){
    if (mainStack.isEmpty()) return;
    mainStack.pop();
    mainStack.pop();
  }
  public int getMin() {
    if (minStack.isEmpty()) throw new RuntimeException("Stack is empty");
    return minStack.peek();
  }


  public static void main(String[] args) {
    MinStack minStack = new MinStack();
    minStack.push(1);
    minStack.push(-1);
    minStack.push(-3);
    minStack.push(-4);
    minStack.push(-1);
    System.out.println(minStack.getMin());
  }
}
